const { Card, Button, Input, Select, Icon, TreeSelect, DatePicker, Row, Col } = antd;
const { MonthPicker, RangePicker } = DatePicker;
const InputGroup = Input.Group;
const Option = Select.Option;
const TreeNode = TreeSelect.TreeNode;


class SelectJob extends React.Component {
    state = mountData;
    componentDidMount() {
        var _this = this;
        if (vui.GetCookie("JobID") == null) {
            UserProductJob.map(function (target, index) {
                _this.setState({ value: target.JobName });
                vui.Cookie(
                    { name: "JobID", value: target.ID }
                )
                return
            })
        } else {
            UserProductJob.map(function (target, index) {
                if (target.ID == vui.GetCookie("JobID")) {
                    _this.setState({ value: target.JobName });
                }
            })
        }
    }
    render() {
        var Data = UserProductJob;
        var newData = [];
        function insertData(data, arr, hasDisabled) {
            Data.map(function (_target, _index) {
                newData.push({
                    label: _target.JobName,
                    value: _target.JobName,
                    key: _target.ID,
                    disabled: false,
                    children: []
                })
            })
        }
        insertData(Data, newData, true);
        return (
            <InputGroup compact>
                <Input addonBefore={SelectJobMsg.addonBefore} style={{ width: '80px' }} defaultValue="" />
                <TreeSelect
                    treeData={newData}

                    showSearch
                    style={{ width: "calc(100% - 80px)", marginLeft: "-1px" }}
                    value={this.props.value}

                    dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                    placeholder={SelectJobMsg.placeholder}
                    allowClear
                    treeDefaultExpandAll
                    onChange={this.props.selectOnChange}
                />

            </InputGroup>
        );
    }
}